<%@ include file="../common.jsp"%>

<script type="text/javascript">
	$(document).ready(
		
		function() {
			$("#companySelect").val('<c:out value="${companySelect}"></c:out>');
		});
</script>

<c:choose>
	<c:when test="${size eq 0}">
		No Records Found.
	</c:when>
	<c:otherwise>
		<table class="viewDetails" id="viewUsers">
			<c:choose>
				<c:when test="${sizeOfUserList eq 0}">
					<tr class="heading">
						<td>No Records Found. </td>
					</tr>
				</c:when>
				<c:otherwise>
					<tr class="adminTableMainHeaderColor tableChildHeaderFont">
						<th colspan="6"><span class="searchResultsCaption" > VIEW USERS </span> </th>
					</tr>
					<tr class="even" align="left">
						<td colspan="6">
							<c:if test="${companyId eq 0}">
							Filter by Company 
							<select id="companySelect" onchange="filterUsersTable('viewuser');">
								
									<option value="0">ALL</option>
								
								<c:forEach items="${companyMap}" var="item">
									<option value="${item.key}">${item.value.cdName}</option>
								</c:forEach>
								
						   </select>
						   </c:if> 
						</td>
					</tr>
					<tr class="heading">
						<th> Name </th>
						<th> Id </th>
						<th> Company </th>
						<th> Business Unit </th>		
						<th> Department </th>	
						<th> Email Id </th>						
					</tr>	
				
					<c:forEach items="${userList}" varStatus="loop" var="item">
						<c:set var="tabColor" value="odd"></c:set>
					     	<c:if test="${(loop.index % 2) eq 0}">
					        	<c:set var="tabColor" value="even"></c:set>
					        </c:if>
					<tr class="${tabColor}">
						<td> ${item.userDisplayName} </td>
						<td> ${item.username} </td>
						<td> ${companyMap[item.cdId].cdName} </td>
						<td> ${locationMap[item.buId]} </td>		
						<td> ${departmentMap[item.deptId]} </td>
						<td> ${item.emailId} </td>				
					</tr>	
					</c:forEach>
				</c:otherwise>
			</c:choose>
		</table>
		
	</c:otherwise>
</c:choose>
